//1.0导入vue核心包
import Vue from 'vue';
//2.0导入Vue对象
import App from './App.vue';

//导入vue-resource，绑定后会在vue对象上注入一个$http
import vueResource from 'vue-resource';
Vue.use(vueResource);


//导入全局组件vue-loadding,那么在任何组件都可以直接使用，不需要导入和注册组件
// import vueLoading from 'vue-loading-template';
// Vue.component('vue-loading',vueLoading);

//vue-preview图片预览
// import VuePreview from 'vue-preview';
// Vue.use(VuePreview);

//全局导入slider子组件
import slider from './components/subcom/slider.vue';
Vue.component('slider',slider);

//集成路由
import vueRouter from 'vue-router';
Vue.use(vueRouter);
//导入组件
import home from './components/home.vue';
import membership from './components/membership/membership.vue';
import car from './components/shopcar/car.vue';
import search from './components/search/search.vue';
import photolist from './components/photo/photolist.vue';
import photoinfo from './components/photo/photoinfo.vue';
import newslist from './components/news/newslist.vue';
import newsinfo from './components/news/newsinfo.vue';
import goodslist from './components/goods/goodslist.vue';
import goodsinfo from './components/goods/goodsinfo.vue';
import goodsdesc from './components/goods/goodsdesc.vue';
import goodscomments from './components/goods/goodscomments.vue';
var router=new vueRouter({
    //改变路由激活时的class名称，默认是router-link-active
    linkActiveClass:'mui-active',
    routes:[
        {path:'*',redirect:'/home'}, //定义不存在的页面   
        {path:'/',redirect:'/home'},        
        {path:'/home',component:home},
        {path:'/membership',component:membership},
        {path:'/car',component:car},
        {path:'/search',component:search},
        {path:'/photo/photolist',component:photolist},
        {path:'/photo/photoinfo/:id',component:photoinfo},
        {path:'/news/newslist',component:newslist},
        {path:'/news/newsinfo/:id',component:newsinfo},
        {path:'/goods/goodslist',component:goodslist},
        {path:'/goods/goodsinfo/:id',component:goodsinfo},
        {path:'/goods/goodsdesc/:id',component:goodsdesc},
        {path:'/goods/goodscomments/:id',component:goodscomments},
    ]
});
 

//定义全局过滤器
//   Vue.filter('datefml',function(input,fmlString){
//         var res='';
//         var data=new Date(input);
//         var year=data.getFullYear();
//         var month=data.getMonth()+1;
//         month=month>=10?month:'0'+month;
//         var day=data.getDate();
//         day=day>=10?day:'0'+day;
//        if(fmlString=='yyyy-MM-dd'){
            
//             res=year+'-'+month+'-'+day;
//        }else if(fmlString=='yyyy-MM-dd HH:mm:ss'){
      
//             var hour=data.getHours();
//             hour=hour>=10?hour:'0'+hour;
//             var minute=data.getMinutes();
//             minute=minute>=10?minute:'0'+minute;
//             var second=data.getSeconds();
//             second=second>=10?second:'0'+second;
//             res=year+'-'+month+'-'+day+" "+hour+':'+minute+':'+second;
//        }
//         return res;
//     });
//使用moment组件实现
import moment from "moment";
Vue.filter('datefmt',function(input,fmlstring){
    return moment(input).format(fmlstring);
})

//导入mintUI(使用组件的时候要绑定给Vue)
import 'mint-ui/lib/style.css';
import mintUi from 'mint-ui';

Vue.use(mintUi);
//全局导入mui
import '../statics/mui/css/mui.css';
    
//导入全局css
import '../statics/css/site.css';

//创建vue对象
new Vue({
    el:"#app",
    router:router,
    render:c=>c(App),
})
